package main

import (
	"flag"
	"fmt"
	"os"

	"diff.wang/asynqsrv/crond/internal/config"
	"diff.wang/asynqsrv/crond/internal/svc"
	"github.com/zeromicro/go-zero/core/conf"
	"github.com/zeromicro/go-zero/core/logx"
)

var configFile = flag.String("f", "etc/app.yaml", "Specify the config file")

func main() {
	flag.Parse()

	var c config.Config
	conf.MustLoad(*configFile, &c)

	logx.DisableStat()
	// log、prometheus、trace、metricsUrl.
	if err := c.SetUp(); err != nil {
		panic(err)
	}

	svcCtx := svc.NewServiceContext(c)

	if err := svcCtx.PeriodicTaskManager.Run(); err != nil {
		fmt.Println(err)
		logx.Errorf("!!!PeriodicTaskManager!!!  run err:%+v", err)
		os.Exit(1)
	}
}
